﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using UpdaterForm.Annotations;

namespace UpdaterForm
{
    [Serializable]
    public class UpdateLog : INotifyPropertyChanged
    {
        private List<String> _transferedFiles; 

        [XmlElement("UpdateName")]
        public String Name { get; set; }
        [XmlElement("ApplyTime")]
        public DateTime Time { get; set; }
        [XmlElement("State")]
        public UpdateState State { get; set; }

        private String _failReason;
        [XmlElement("FailReason")]
        public String FailReason {
            get { return _failReason; }
            set
            {
                _failReason = value;
                OnPropertyChanged("FailReason");
            }
        }

        //TODO: mozet peredelat v dictionary, togda leg4e bedet iskat v kolekcii
        [XmlElement("TransferedFile")]
        public List<String> TransferedFiles {
            get
            {
                if (_transferedFiles==null){
                    _transferedFiles = new List<string>();
                }
                return _transferedFiles;
            }
            set{
                _transferedFiles = value;
            } 
        }


        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
